package cc.vv.btpartyjob.partymanager.adapter

import android.text.TextUtils
import android.widget.TextView
import cc.vv.baselibrary.adapter.SimpleCommonAdapter
import cc.vv.baselibrary.adapter.holder.ExtendViewHolder
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.moudel.bean.PolicyDocBean

/**
 * 政策文件adapter
 * Created by Chen.qi on 2018/10/24.
 */
class PolicyDocumentAdapter(layoutResId: Int) : SimpleCommonAdapter<PolicyDocBean>(layoutResId) {
    override fun convert(helper: ExtendViewHolder, item: PolicyDocBean, position: Int) {
        //标题
        helper.getView<TextView>(R.id.tv_ipd_title)?.text = item.title
        //时间
        val viewTime = helper.getView<TextView>(R.id.tv_ipd_time)
        if (!TextUtils.isEmpty(item.releaseTime) && item.releaseTime!!.length > 10) {
            val substring = item.releaseTime!!.substring(0, 10)
            viewTime?.text = substring
        } else {
            viewTime?.text = item.releaseTime
        }
    }
}